﻿namespace EasyWeb.Test
{
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class EWSerializationInfo_Test
    {
        [TestMethod]
        public void All_Test()
        {
            var info = new EWSerializationInfo();

            var v01 = Guid.NewGuid();
            var v02 = true;
            var v03 = (byte)10;
            var v04 = 'a';
            var v05 = DateTime.Now;
            var v06 = DateTimeOffset.Now;
            var v07 = TimeSpan.FromHours(20);
            var v08 = 10.5M;
            var v09 = 10.6D;
            var v10 = 10.7F;
            var v11 = (short)10;
            var v12 = 20;
            var v13 = 30L;
            var v14 = (sbyte)10;
            var v15 = (ushort)10;
            var v16 = (uint)20;
            var v17 = (ulong)30;
            var v18 = new Guid?(Guid.NewGuid());
            var v19 = new bool?(true);
            var v20 = new byte?((byte)10);
            var v21 = new char?('d');
            var v22 = new DateTime?(DateTime.Now);
            var v23 = new DateTimeOffset?(DateTimeOffset.Now);
            var v24 = new TimeSpan?(TimeSpan.FromHours(10));
            var v25 = new decimal?(10.5M);
            var v26 = new double?(10.4D);
            var v27 = new float?(10.3F);
            var v28 = new short?((short)10);
            var v29 = new int?(10);
            var v30 = new long?(20L);
            var v31 = new sbyte?((sbyte)10);
            var v32 = new ushort?((ushort)20);
            var v33 = new uint?((uint)10);
            var v34 = new ulong?((ulong)30);
            var v35 = "aaa";
            var v36 = TestType.BBB;

            info.AddValue("v01", v01);
            info.AddValue("v02", v02);
            info.AddValue("v03", v03);
            info.AddValue("v04", v04);
            info.AddValue("v05", v05);
            info.AddValue("v06", v06);
            info.AddValue("v07", v07);
            info.AddValue("v08", v08);
            info.AddValue("v09", v09);
            info.AddValue("v10", v10);
            info.AddValue("v11", v11);
            info.AddValue("v12", v12);
            info.AddValue("v13", v13);
            info.AddValue("v14", v14);
            info.AddValue("v15", v15);
            info.AddValue("v16", v16);
            info.AddValue("v17", v17);
            info.AddValue("v18", v18);
            info.AddValue("v19", v19);
            info.AddValue("v20", v20);
            info.AddValue("v21", v21);
            info.AddValue("v22", v22);
            info.AddValue("v23", v23);
            info.AddValue("v24", v24);
            info.AddValue("v25", v25);
            info.AddValue("v26", v26);
            info.AddValue("v27", v27);
            info.AddValue("v28", v28);
            info.AddValue("v29", v29);
            info.AddValue("v30", v30);
            info.AddValue("v31", v31);
            info.AddValue("v32", v32);
            info.AddValue("v33", v33);
            info.AddValue("v34", v34);
            info.AddValue("v35", v35);
            info.AddValue("v36", v36);

            Assert.AreEqual(v01, info.GetGuid("v01"));
            Assert.AreEqual(v02, info.GetBoolean("v02"));
            Assert.AreEqual(v03, info.GetByte("v03"));
            Assert.AreEqual(v04, info.GetChar("v04"));
            Assert.AreEqual(v05, info.GetDateTime("v05"));
            Assert.AreEqual(v06, info.GetDateTimeOffset("v06"));
            Assert.AreEqual(v07, info.GetTimeSpan("v07"));
            Assert.AreEqual(v08, info.GetDecimal("v08"));
            Assert.AreEqual(v09, info.GetDouble("v09"));
            Assert.AreEqual(v10, info.GetSingle("v10"));
            Assert.AreEqual(v11, info.GetInt16("v11"));
            Assert.AreEqual(v12, info.GetInt32("v12"));
            Assert.AreEqual(v13, info.GetInt64("v13"));
            Assert.AreEqual(v14, info.GetSByte("v14"));
            Assert.AreEqual(v15, info.GetUInt16("v15"));
            Assert.AreEqual(v16, info.GetUInt32("v16"));
            Assert.AreEqual(v17, info.GetUInt64("v17"));
            Assert.AreEqual(v18, info.GetNullableGuid("v18"));
            Assert.AreEqual(v19, info.GetNullableBoolean("v19"));
            Assert.AreEqual(v20, info.GetNullableByte("v20"));
            Assert.AreEqual(v21, info.GetNullableChar("v21"));
            Assert.AreEqual(v22, info.GetNullableDateTime("v22"));
            Assert.AreEqual(v23, info.GetNullableDateTimeOffset("v23"));
            Assert.AreEqual(v24, info.GetNullableTimeSpan("v24"));
            Assert.AreEqual(v25, info.GetNullableDecimal("v25"));
            Assert.AreEqual(v26, info.GetNullableDouble("v26"));
            Assert.AreEqual(v27, info.GetNullableSingle("v27"));
            Assert.AreEqual(v28, info.GetNullableInt16("v28"));
            Assert.AreEqual(v29, info.GetNullableInt32("v29"));
            Assert.AreEqual(v30, info.GetNullableInt64("v30"));
            Assert.AreEqual(v31, info.GetNullableSByte("v31"));
            Assert.AreEqual(v32, info.GetNullableUInt16("v32"));
            Assert.AreEqual(v33, info.GetNullableUInt32("v33"));
            Assert.AreEqual(v34, info.GetNullableUInt64("v34"));
            Assert.AreEqual(v35, info.GetString("v35"));
            Assert.AreEqual(v36, info.GetEnum<TestType>("v36"));
        }

        public enum TestType { AAA, BBB }
    }
}
